]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
status/autoRotate: Port to quick settings
authorFlorian Müllner <fmuellner@gnome.org>
Wed, 27 Jul 2022 01:46:43 +0000 (03:46 +0200)
committerMarge Bot <marge-bot@gnome.org>
Tue, 2 Aug 2022 16:05:28 +0000 (16:05 +0000)
On devices where auto-rotation is supported, (un)locking the
orientation is a common enough action to not bury it in a menu.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2392>

js/js-resources.gresource.xml
js/ui/panel.js
js/ui/status/autoRotate.js [new file with mode: 0644]
js/ui/status/system.js
po/POTFILES.in

index 87adfd14032d622f491d7bc5bbaa4725a63b0e35..71d3d492f35735cf0533b8b26139e2f419827a94 100644 (file)
     <file>ui/components/keyring.js</file>
 
     <file>ui/status/accessibility.js</file>
+    <file>ui/status/autoRotate.js</file>
     <file>ui/status/brightness.js</file>
     <file>ui/status/dwellClick.js</file>
     <file>ui/status/location.js</file>
index 0b0c50153cbe5a6083e649b2c35127c67259c6ce..95e9740ff7fdf8158a5896469eff46b12fe60d8b 100644 (file)
@@ -425,6 +425,7 @@ class QuickSettings extends PanelMenu.Button {
         this._thunderbolt = new imports.ui.status.thunderbolt.Indicator();
         this._nightLight = new imports.ui.status.nightLight.Indicator();
         this._rfkill = new imports.ui.status.rfkill.Indicator();
+        this._autoRotate = new imports.ui.status.autoRotate.Indicator();
         this._unsafeMode = new UnsafeModeIndicator();
         this._power = new imports.ui.status.power.Indicator();
 
@@ -435,6 +436,7 @@ class QuickSettings extends PanelMenu.Button {
         if (this._bluetooth)
             this._indicators.add_child(this._bluetooth);
         this._indicators.add_child(this._rfkill);
+        this._indicators.add_child(this._autoRotate);
         this._indicators.add_child(this._unsafeMode);
         this._indicators.add_child(this._power);
 
@@ -445,6 +447,7 @@ class QuickSettings extends PanelMenu.Button {
             this._addItems(this._bluetooth.quickSettingsItems);
         this._addItems(this._nightLight.quickSettingsItems);
         this._addItems(this._rfkill.quickSettingsItems);
+        this._addItems(this._autoRotate.quickSettingsItems);
         this._addItems(this._unsafeMode.quickSettingsItems);
         this._addItems(this._power.quickSettingsItems);
     }
diff --git a/js/ui/status/autoRotate.js b/js/ui/status/autoRotate.js
new file mode 100644 (file)
index 0000000..bde3b80
--- /dev/null
@@ -0,0 +1,45 @@
+/* exported Indicator */
+const {Gio, GObject} = imports.gi;
+
+const SystemActions = imports.misc.systemActions;
+
+const {QuickToggle, SystemIndicator} = imports.ui.quickSettings;
+
+const RotationToggle = GObject.registerClass(
+class RotationToggle extends QuickToggle {
+    _init() {
+        this._systemActions = new SystemActions.getDefault();
+
+        super._init({
+            label: _('Auto Rotate'),
+        });
+
+        this._systemActions.bind_property('can-lock-orientation',
+            this, 'visible',
+            GObject.BindingFlags.DEFAULT |
+            GObject.BindingFlags.SYNC_CREATE);
+        this._systemActions.bind_property('orientation-lock-icon',
+            this, 'icon-name',
+            GObject.BindingFlags.DEFAULT |
+            GObject.BindingFlags.SYNC_CREATE);
+
+        this._settings = new Gio.Settings({
+            schema_id: 'org.gnome.settings-daemon.peripherals.touchscreen',
+        });
+        this._settings.bind('orientation-lock',
+            this, 'checked',
+            Gio.SettingsBindFlags.INVERT_BOOLEAN);
+
+        this.connect('clicked',
+            () => this._systemActions.activateLockOrientation());
+    }
+});
+
+var Indicator = GObject.registerClass(
+class Indicator extends SystemIndicator {
+    _init() {
+        super._init();
+
+        this.quickSettingsItems.push(new RotationToggle());
+    }
+});
index 32320ab82993ea6985fda2271174a43f6e71fe9c..b218e3e541b258625b6dee19d47c85facdc1c5fb 100644 (file)
@@ -62,27 +62,6 @@ class Indicator extends PanelMenu.SystemIndicator {
         let bindFlags = GObject.BindingFlags.DEFAULT | GObject.BindingFlags.SYNC_CREATE;
         let item;
 
-        item = new PopupMenu.PopupImageMenuItem(
-            this._systemActions.getName('lock-orientation'),
-            this._systemActions.orientation_lock_icon);
-
-        item.connect('activate', () => {
-            this.menu.itemActivated(BoxPointer.PopupAnimation.NONE);
-            this._systemActions.activateLockOrientation();
-        });
-        this.menu.addMenuItem(item);
-        this._orientationLockItem = item;
-        this._systemActions.bind_property('can-lock-orientation',
-            this._orientationLockItem, 'visible',
-            bindFlags);
-        this._systemActions.connect('notify::orientation-lock-icon', () => {
-            let iconName = this._systemActions.orientation_lock_icon;
-            let labelText = this._systemActions.getName("lock-orientation");
-
-            this._orientationLockItem.setIcon(iconName);
-            this._orientationLockItem.label.text = labelText;
-        });
-
         let app = this._settingsApp = Shell.AppSystem.get_default().lookup_app(
             'org.gnome.Settings.desktop');
         if (app) {
index 2f6bd0ae76aa2605afd66a50b195f674c8e228a5..a47bd8adbad66aecbae78619b7ba19d80cc6adb9 100644 (file)
@@ -56,6 +56,7 @@ js/ui/searchController.js
 js/ui/shellEntry.js
 js/ui/shellMountOperation.js
 js/ui/status/accessibility.js
+js/ui/status/autoRotate.js
 js/ui/status/bluetooth.js
 js/ui/status/brightness.js
 js/ui/status/dwellClick.js